<template>
  <div>
    <div class="foods" v-for="(foods, index) in FoodsInfo" :key="index" @click="toStore(foods)">
      <img :src="foods.pic" alt="" />
      <!-- 右侧信息 -->
      <div class="foods-info">
        <h2>{{ foods.title }}</h2>
        <span>月售：{{ foods.volume }}</span>
        <span>人均：￥{{ foods.price }}</span>
        <div class="foods-tag">
          <!-- 标签 -->
          <van-tag size="medium" text-color="black" color="#ffc400" v-for="(tag, index) in foods.label" :key="index"> {{ tag }} </van-tag>
        </div>
      </div>
    </div>
  </div>
</template>
<!-- // ------------------------------------------------------------------------------------------ -->
<script setup>
import stores from '../view/Store/Store.vue'
import { useRouter } from 'vue-router'
import { FoodsShoper } from '../store/index'
import { storeToRefs } from 'pinia'
const store = FoodsShoper()
// 路由
const router = useRouter()
const props = defineProps(['FoodsInfo'])

const toStore = (val) =>{
  console.log(val)

  store.$patch((state)=>{
    state.FoodsShopInfo = val
  })
  
  router.push('/store')
}
</script>
<!-- //------------------------------------------------------------------------------------------ -->
<script>
export default {
  // props: { FoodsInfo: Array },
  data() {
    return {
      title: '' //商品标题
    }
  }
  // methods: {
  //   toStore(foods) {
  //     this.$router.push('/store')
  //     console.log(foods)
  //   }
  // }
}
</script>
<!-- // ------------------------------------------------------------------------------------------ -->
<style lang="less">
.foods {
  background-color: #fff;
  margin: 10px 0;
  border-radius: 15px;
  display: flex;
  img {
    padding: 10px;
    width: 100px;
    height: 100px;
    border-radius: 15px;
  }
  .foods-info {
    display: flex;
    // height: 80%;
    flex-direction: column;
    justify-content: space-between;
    h2 {
      font-weight: bold;
    }
    span {
      display: block;
      font-size: 12px;
    }
    .foods-tag {
      display: flex;
      .van-tag {
        margin: 0 3px;
      }
    }
    padding: 10px;
  }
}
</style>
